/*
 * @Author: lp
 * @Date: 2022-04-29 10:14:37
 * @LastEditTime: 2022-04-29 10:42:12
 * @LastEditors: Please set LastEditors
 * @Description: 数据加密
 * @FilePath: \nien-vue3-admin\src\utils\jsencrypt.ts
 */
import JSEncrypt from 'jsencrypt'

const encrypt = new JSEncrypt() 
// 加密公钥
const pubKey = `MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCVBeiNxFRoVnQs3hDnXm8mUxtg
q0iHTj4lcd6qttHGAgqZcGGJUjLma/gm5Jo5kzb8ETtsGLtgK/2u7ducb68Hplwn
ypzHs36eDZmbF3JYTH2fCmZgRXtdQ5icCtssEJ6jlrCYueDjKx9I7VuwoQHrp+4f
Dkco8Z9xOGbM1TwmBwIDAQAB`
encrypt.setPublicKey(pubKey)
const privateKey = `MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBAJUF6I3EVGhWdCze
EOdebyZTG2CrSIdOPiVx3qq20cYCCplwYYlSMuZr+CbkmjmTNvwRO2wYu2Ar/a7t
25xvrwemXCfKnMezfp4NmZsXclhMfZ8KZmBFe11DmJwK2ywQnqOWsJi54OMrH0jt
W7ChAeun7h8ORyjxn3E4ZszVPCYHAgMBAAECgYEAifqWf+ywWorxtjlGXXNKZqm8
R51P4jfHwtPT3yy2vidVuQwcwxCgoEiH0zsGsRhlaK5r3oJnu3v/vt/s3sNpwrnL
EIFRdBC3kf6TtKwQeEtOF2py2M3DJTfJGtFqCSTyT/VUKJO8+xAChPFIxZsIv/a2
xQ1Jx+tefhTDV/rma8ECQQDEJgW5JKIeJzGVkp/wKUmYPAj2UgmysH64iguVo8wD
+Z29SOW9eO/uzs0g2ntt6mz0ctlcSZUlURtf/17+Q68dAkEAwn64rf9UdEAXJ5Mz
uIb4yK6oTTXFgoIFv9EGipgG2aqSL8oxYhuLF9+q3X2z0Q11UhT9yfVjPh7XgJQP
t1GscwJBAKGC3XuSGpvRkhajYWcT2DGuXYLWEn48rlut79QLx9YOGEDgYawehRKS
3n2K6c+cFJNEbo57WIAdxPjLAqFDglECQERut+Yox3tbrYn0JieP/esGYRtBhywD
OaijEC0ljot5k5QTDUsaq9cLkJ/8AY/Vr2jhD+bGW1PZIDQSZHE44HcCQQCe1iKb
iBoBMNsGx9urZyPJs/QUwh0YpeleWmSh1GE2UXO/depBnQHw6DX5W15bUpbJhSK2
OMau/5RlPDNltqMX`
encrypt.setPrivateKey(privateKey)
// 加密
function desEncrypt(data) {
  // 对需要加密的数据进行加密
  return encrypt.encrypt(data)
}
// 加密
function desDecrypt(data) {
  // 对需要加密的数据进行解密
  return encrypt.decrypt(data)
}

export {
  desEncrypt,
  desDecrypt,
}
